Xbasic

SQL::ConnectionToString Method

Syntax

String as C = ToString(SQLStatement as C [, Arguments as SQL::Arguments][, RowsToCopy = -1 as N [, StartRow = 1 as N [, ColumnSeparator as C [,RowSeparator as C [, ColumnReferences as SQL::TableInfo [, UserContext as P]]]]]])

Arguments

SQLStatementCharacter

A SQL SELECT statement.

ArgumentsSQL::Arguments

A SQL::Arguments object. One or more arguments to be resolved when the SELECT statement is executed.

RowsToCopyNumeric

Default = -1 (all). The number of rows to copy.

StartRowNumeric

Default = 1 (first). The first row to copy.

ColumnSeparatorCharacter

Default = tab. Characters to insert between columns.

RowSeparatorCharacter

Default = CR-LF. Characters to insert between rows.

ColumnReferencesSQL::TableInfo

A SQL::TableInfo object. When data is formatted for a column in the result set: (1) if ReferenceColumns has a column with a matching name, that object will be used to format the data; (2) otherwise the ColumnInfo property of the result set is used to format the data.

UserContextPointer

The user context is passed into the evaluation of the expression when data is formatted.

Returns

StringCharacter

The retrieved data.

Description

Fetch data to a string using a SQL query.

Discussion

The ToString() method fetches data to a string using a SQL query.

Example

dim conn as SQL::Connection
dim connString as C
dim query as C
query = "select firstname, lastname from customer where lastname > 'm'"
connString = "{A5API='Access', FileName='c:\program files\a5v8\mdbfiles\alphasports.mdb'}"
if .not. conn.open(connString)
    ui_msg_box("Error", conn.CallResult.text)
    end
end if
ui_msg_box("Results", conn.ToString(query))
conn.close()

This example retrieves four rows of data, starting at the third row. Note : Even though there are no arguments to pass, the following script DIMs and passes the args variable.

dim conn as SQL::Connection
dim connString as C
dim query as C
dim args as SQL::Arguments
query = "select firstname, lastname from customer where lastname > 'm'"
connString = "{A5API='Access', FileName='c:\program files\a5v8\mdbfiles\alphasports.mdb'}"
if .not. conn.open(connString)
    ui_msg_box("Error", conn.CallResult.text)
    end
end if
ui_msg_box("Results", conn.ToString(query, args, 4, 3, "|", crlf()))
conn.close()

See Also